﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using Model;

namespace GataBaseSys
{
    public partial class RegInFrm : System.Web.UI.Page
    {
        GataBaseBLL bll = new GataBaseBLL();
        UserInfo info = new UserInfo();
        protected void Page_Load(object sender, EventArgs e)
        {
            SignIn info = Session["UserInfo"] as SignIn;
            int id = info.SignInID;
            this.lblCode.Text = Convert.ToInt32(id).ToString();
            //Session["uid"] = this.lblCode.Text;
        }

        protected void btnInsert_Click(object sender, EventArgs e)
        {
            if (this.txtName.Text.Trim()==""|| this.txtCard.Text.Trim() == "" || this.txtEmail.Text.Trim() == "" || this.txtMoney.Text.Trim() == "" || this.txtPhone.Text.Trim() == "")
            {
                Response.Write("<script>alert('不能为空!')</script>");
            }
            else
            {
                info.UserCode = Convert.ToInt32(this.lblCode.Text);//编号记录
                info.UserName = this.txtName.Text.Trim();//姓名录入
                if (this.RadMen.Checked == true)//男女按钮选中
                {
                    info.UserGender = "男";
                }
                else if (this.RadWomen.Checked == true)
                {
                    info.UserGender = "女";
                }
                info.UserCard = this.txtCard.Text.Trim();//身份证号码
                info.UserTelephone = this.txtPhone.Text.Trim();//电话号码
                info.UserBalance = Convert.ToDecimal(this.txtMoney.Text.Trim());//持有金额
                info.UserMailbox = this.txtEmail.Text.Trim();//电子邮箱
                if (this.RadGrand.Checked == true)
                {
                    info.UserState = "普通用户";
                }
                if (bll.Identity(info))
                {
                    Response.Write("<script>alert('身份信息完善成功')</script>");
                    Response.Redirect("Login.aspx");
                }
                else
                {
                    Response.Write("<script>alert('身份信息注册失败')</script>");
                }
            }
        }
    }
}